import { defineStore } from "pinia";
export const usePlayerStore = defineStore('player',{
    state:()=>({
        id: localStorage.getItem('playerId') || crypto.randomUUID(),
        name: localStorage.getItem('playerName') || '玩家'+ Math.floor(Math.random()*1000),
        score: 0,
        color: localStorage.getItem('playerColor') || '#000000'
    }),
    actions:{
        setName(name) {
            this.name = name
        },
        setScore(score) {
            this.score = score
        },
        setColor(color) {
            this.color = color
            localStorage.setItem('playerColor', color)
        }
    }
})